package com.bhp.ruoyiplus.project.demo.controller;

import com.bhp.ruoyiplus.framework.web.controller.BaseController;
import com.bhp.ruoyiplus.framework.web.domain.AjaxResult;
import com.bhp.ruoyiplus.framework.web.page.TableDataInfo;
import com.bhp.ruoyiplus.project.demo.domain.Demo;
import com.bhp.ruoyiplus.project.demo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName DemoController
 * @Description TODO
 * @Author 北海派
 * @Date 2020/5/18 19:22
 * @Version 1.0
 **/
@RestController
@RequestMapping("/demo")
public class DemoController extends BaseController {

    @Autowired
    private DemoService demoService;

    @GetMapping()
    public AjaxResult get() {
        Demo demo = demoService.getById("1");
        if (null==demo){
            return AjaxResult.error("无数据");
        }
        return AjaxResult.success(demo);
    }

    @GetMapping("/list")
    public TableDataInfo getList() {
        startPage();
        return getDataTable(demoService.list());
    }
}
